#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

unshift(@INC, '.');
require qpdf_test_helpers;

chdir("qpdf") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('dangling-refs');

my @dangling = (qw(minimal dangling-refs dangling-bad-xref));
my $n_tests = 2 * scalar(@dangling);

foreach my $f (@dangling)
{
    $td->runtest("dangling refs: $f",
                 {$td->COMMAND => "test_driver 53 $f.pdf"},
                 {$td->FILE => "$f-dangling.out", $td->EXIT_STATUS => 0},
                 $td->NORMALIZE_NEWLINES);
    $td->runtest("check output",
                 {$td->COMMAND => "qpdf-test-compare a.pdf $f-dangling-out.pdf"},
                 {$td->FILE => "$f-dangling-out.pdf", $td->EXIT_STATUS => 0});
}
cleanup();
$td->report($n_tests);
